﻿using QFramework;

namespace GameJamLight
{
    /// <summary>
    /// 加载当前关卡命令
    /// </summary>
    public class LoadLevelSceneCommand : AbstractCommand
    {
        private readonly float stepIn, stepOut;

        public LoadLevelSceneCommand(float stepIn = 0, float stepOut = 0)
        {
            this.stepIn = stepIn;
            this.stepOut = stepOut;
        }

        protected override void OnExecute()
        {
            var gameModel = this.GetModel<IGameModel>();
            string name = gameModel.CurLevelID == 0 ? "Level1" : "Level" + gameModel.CurLevelID;
            this.SendCommand(new LoadSceneCommand(name, stepIn, stepOut,()=> 
            {
                this.GetSystem<IKnockCheckSystem>().Start();
                this.GetSystem<ILevelTimingSystem>().Start();
            }));
        }
    }
}